<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="<%=basePath %>web/js/jquery.min.js"></script>
    <script src="<%=basePath %>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath %>web/js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="<%=basePath %>web/themes/icon.css">
    <link rel="stylesheet" href="<%=basePath %>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>web/css/wu.css">
    <style type="text/css">
        .subck { display:none }/*合计单元格样式*/
    </style>
    <script>
        var  selectIndex = -1;

        function hideTable(){
            $("#searchdiv").toggle();
        }
        //关闭
        function closeLog(){
           self.parent.$("#list").dialog("close"); 
        }
        function reset(){
           $("#form1").form('reset');
           $("#companyList").datagrid('load',{});
           //$("#form1")[0].reset();
        }
        $(function(){
            
            //添加下拉框
            /* $('#cc').combobox({    
			    url:'/kxmanage/instroageBill/getCompanyList.json',    
			    valueField:'code',    
			    textField:'name'   
			}); */
            //数据表格
            $("#companyList").datagrid({
                fit:true,
                url:'/kxmanage/instroageBill/getPartPriceFive.json',
                rownumbers:false,
                pageNumber:1,
                pageSize:5,
                pageList:[5,10,15],
                checkOnSelect:false,
                queryParams: {
					partCode:$("#partCode").val()
	            },
                columns:[[
                    {field:'instroageDate',title:'日期',width:140,
                        formatter:function(value,row,index){
                            return new Date(value).toLocaleDateString().replace(/\//g,'-');
                    }},
                    {field:'partName',title:'配件名称',width:180},
                    {field:'size',title:'配件型号',width:60},
                    {field:'amount',title:'进货数量',width:60},
                    {field:'price',title:'进货价格',width:100},
                    {field:'customName',title:'进货单位',width:100}
                ]],
                toolbar:'#wu_toolbar',
            })
	        $("#search_btn").click(function(){
	            $("#companyList").datagrid('reload',serializeJson())
	        }) 
        })
        
       //表单序列化
        function serializeJson(){  
            var serializeObj={};  
            var array=$("#form1").serializeArray();  
            var str=$("#form1").serialize();  
            $(array).each(function(){  
                if(serializeObj[this.name]){  
                    if($.isArray(serializeObj[this.name])){  
                        serializeObj[this.name].push(this.value);  
                    }else{  
                        serializeObj[this.name]=[serializeObj[this.name],this.value];
                    }  
                }else{  
                    serializeObj[this.name]=this.value;   
                }  
            });  
                return serializeObj;  
            }; 
        //指定列求和
        function compute(colName) {
            var rows = $('#productList').datagrid('getRows');
            var total = 0;
            for (var i = 0; i < rows.length; i++) {
                total += parseFloat(rows[i][colName]);
            }
            return total;
        }
      
    </script>
</head>
<body  class="easyui-layout">
<div  id="wu_toolbar">
    该型号配件平均成本价 ￥：${instroagePrice }，及最近5次进价
    <input type="hidden" id="partCode" value="${partCode }"/>
</div>
<div id="companyList" class="easyui-datagrid">

</div>
</body>
</html>